<?php $this->load->view('header/admin'); ?>
<div id="main">
    <div class="container">
        <div class="span-17 colborder" id="content">
        <?php if (isset($messages)) echo $messages; ?>
            <h3 class="caps">Clubs</h3>
	        <?php if ($clubs): ?>
	           <div class="span-16 last">
                    <div class="box span-6">
                        <p>Click on the name of the club for more information</p>
                        <ul class="enumeration">
                        <?php foreach($clubs as $c): ?>
                            <li class="prepend-top">
                                <?php echo anchor('admin/clubs/see/'.$c->id, $c->name, 
                                    'class="club-info'.(($selected == $c->id)? ' selected' : '').'" id="club-'.$c->id.'"')?>&nbsp;
                            </li>
                        <?php endforeach; ?>
                        </ul>
                    </div>
                    <div id="club-details" class="box span-9 last" style="">
                        <h3 class="section-title">Name</h3>
	                    <dl>
	                        <dd id="club-name"><?php echo $club->name; ?></dd>
                            <dt class="caps prepend-top">Since: </dt>
                            <dd id="club-since"><?php echo $club->since; ?></dd>
	                        <dt class="caps prepend-top">Description: </dt> 
	                        <dd id="club-description"><?php echo nl2br($club->description); ?></dd>
	                        <dt class="caps prepend-top">Website: </dt> 
	                        <dd id="club-website"><?php echo $club->website; ?></dd>
	                        <dt class="caps prepend-top">Active: </dt> 
                            <dd id="club-active"><?php echo ($club->active)? 'Yes':'No'; ?></dd>
	                        <dt class="caps prepend-top">Address: </dt> 
	                        <dd id="club-address_line_1"><?php echo $club->address_line_1; ?></dd>
	                        <dd id="club-address_line_2"><?php echo $club->address_line_1; ?></dd>
	                        <dt class="caps prepend-top">Location: </dt> 
	                        <dd id="club-location"><?php echo $club->location; ?></dd>
	                        <dt class="caps prepend-top">Postcode: </dt> 
	                        <dd id="club-postcode"><?php echo $club->postcode; ?></dd>
	                        <dt class="caps prepend-top">Country: </dt> 
	                        <dd id="club-country_code"><?php echo $club->country_code; ?></dd>
	                    </dl>
	                    <div class="span-8 last">
	                        <h3 class="section-title">Authorities</h3>
	                        <?php if (count($club->Authorities) > 0): ?>
	                        <dl>
	                        <?php foreach ($club->Authorities as $e): ?>
	                            <dt><?php echo $e->ClubAuthorityModel[0]->position; ?>: <?php echo anchor('profile/person/edit/'.$e->id, $e->name); ?></dt>
	                        <?php endforeach; ?>
	                        </dl>
	                        <?php else: ?>
	                            <p>None found.</p>
	                        <?php endif; ?>
	                    </div>
	                    
	                    <div class="span-5">
	                        <h3 class="section-title">Contacts</h3>
	                        <?php if (count($club->Contacts) > 0): ?>
	                        <dl>
	                        <?php foreach ($club->Contacts as $e): ?>
	                            <dt><?php echo anchor('profile/person/edit/'.$e->id, $e->name); ?></dt>
	                        <?php endforeach; ?>
	                        </dl>
	                        <?php else: ?>
	                            <p>None found.</p>
	                        <?php endif; ?>
	                    </div>

	                    <div class="span-4 last">
	                        <h3 class="section-title">Admins</h3>
	                        <?php if (count($club->Admins) > 0): ?>
	                        <dl>
	                        <?php foreach ($club->Admins as $e): ?>
	                            <dt>
	                                <?php echo anchor('profile/person/edit/'.$e->id, $e->name); ?>
	                            </dt>
	                        <?php endforeach; ?>
	                        </dl>
                            <?php else: ?>
                                <p>None found.</p>
	                        <?php endif; ?>
	                    </div>
                        <div class="span-9">
                            <p class="detail-actions">
                                [ <?php echo anchor('admin/clubs/edit/'.$club->id, 'Edit', 'class="club-edit" id="club-'.$club->id.'"')?> |
                                  <?php if ($isOwner) echo anchor('admin/clubs/delete/'.$club->id, 'Delete', 'class="club-edit" id="club-'.$club->id.'"').' |'?>
                                  <?php echo anchor('admin/members/index/'.$club->id, 'Members', 'class="club-edit" id="club-'.$club->id.'"')?> ]
                            </p>
                        </div>
                    </div>
                </div>
			<?php endif; ?>
			<div class="span-16">
	        <p><?php if ($isOwner) echo anchor('admin/clubs/add', 'Add Club')?></p>
	        </div>
        </div> <!-- end content -->
        <?php $this->load->view('menu/admin')?>
    </div> <!-- end container -->
    <script type="text/javascript">
    $(document).ready(function() {
        /*$('#club-details').hide();
        
        $('.club-info').click(function(event) {
            event.preventDefault();
            $('#club-details').hide();
            
            var id = event.target.id.match(/^club-([0-9]+)$/);

            $.getJSON('/admin/clubs/ajax/view/'+id[1], function(data) {
                $.each(data, function(key, value) {
                    $('#club-' + key).html(value);
                });

                // special ones
                if (data.active)
                    $('#club-active').html('Yes');
                else
                	$('#club-active').html('No');

                // effect
                $('#club-details').fadeIn();
            });
        });*/
    });
    </script>
</div> <!-- end main -->
<?php $this->load->view('footer/standard');?>
